package com.ymatou.iapi.liveseller.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.liveseller.parameter.UpdateModelBean;
import com.ymatou.iapi.liveseller.service.UpdateModelCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.livetv.Model;
import com.ymttest.database.sqlwapper.LiveRoomWapper;
/**
*更新模特
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_UpdateModel{
	private static UpdateModelBean updatemodelBean;
	private static UpdateModelCall updatemodelCall;
	LiveRoomWapper LiveRoomWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("更新模特");
	}

	@Before
	public void caseUp() {
		updatemodelBean=new UpdateModelBean();
		updatemodelCall=new UpdateModelCall();
		LiveRoomWapper=new LiveRoomWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(updatemodelCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_UpdateModel_001() {
		Logger.start(true,"更新模特成功");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=LiveRoomCallService.CreateModelCall(userid, 1, 1, "nick");
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("200", updatemodelCall.getString("Code"), "验证code");
			Model modle = LiveRoomWapper.selectModelById(id).get(0);
			Logger.verifyEquals(0, modle.getAction(), "验证action");
			Logger.verifyEquals(updatemodelBean.getHeight(), modle.getHeight(), "验证getHeight");
			Logger.verifyEquals(updatemodelBean.getWeight(), modle.getWeight(), "验证getWeight");
			Logger.verifyEquals(updatemodelBean.getNickName(), modle.getNickName(), "验证getNickName");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_002() {
		Logger.start(true,"不输入userid失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
//			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_003() {
		Logger.start(true,"不输入modelId失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
//			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_004() {
		Logger.start(true,"输入modelId和userid不匹配失败");
		try {
			int userid=1;
//			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("201", updatemodelCall.getString("Code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_005() {
		Logger.start(true,"不输入nickName失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
//			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_006() {
		Logger.start(true,"不输入height失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
//			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_007() {
		Logger.start(true,"不输入weight失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(3);
//			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_008() {
		Logger.start(true,"输入height小于1失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(-3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");		
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_009() {
		Logger.start(true,"输入weight小于1失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2");
			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(-5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_UpdateModel_010() {
		Logger.start(true,"输入nickName长度大于10失败");
		try {
			int userid=1;
			LiveRoomCallService.DeleteModel(userid);
			int id=1;
			updatemodelBean.setUserId(userid);
			updatemodelBean.setModelId(id);
			updatemodelBean.setNickName("nick2nick2nick2nick2nick2");
			updatemodelBean.setHeight(3);
			updatemodelBean.setWeight(5);
			updatemodelCall.setData(updatemodelBean);
			updatemodelCall.callService();			
			Logger.verifyEquals("400", updatemodelCall.getString("Code"), "验证code");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}